<?php
    $text='$a = 3; \$a <textarea cols="1" style="border: 2px solid black; padding:2px;"> $a </textarea>'
        . '$a + $b = $c array = var_dump($arr)';
    $a=2; $b=3; $c=$a+$b; $arr = array("bingo", "bongo");
//    $text = 'function myfunc() {$a = 3;} return myfunc();';
//    eval($text);
//    $text = '\$a = $a';
    print eval("return<<<END\n$text\nEND;\n");

function recursive($number, $erg)
{
    $erg *= $number;
    handleArray(getFunctionName(), get_defined_vars());
    if (1 < $number) {
        $erg = recursive($number - 1, $erg);
    }
    if (20 < $erg) {
        $bla = 20;
    }
    if (50 < $erg) {
        $bla = 40;
    }
    handleArray(getFunctionName(), get_defined_vars());
    return $erg;
}

function getFunctionName()
{
    $debug = debug_backtrace();
    return array('line' => $debug[1]['line']
        , 'function' => $debug[1]['function']
        , 'vars' => array()
        )
    ;
}

function handleArray($arrKey, $arrVal, $print = false) {
    static $arr;
    if (true == $print) {
        ob_start();
        print_r('$arr = ');
        print_r($arr);
        print_r("\n");
        $text = ob_get_clean();
        error_log($text);
        var_dump($arr);
        return true;
    }
    $arrKey['vars'] = $arrVal;
    $arr[$arrKey['function']][] = $arrKey;
    return true;
}

echo "<br>" . recursive(5, 1);
handleArray(false, false, true);

